﻿(function ($) {
    //document.write('<script type="text/javascript" src="js/raphael.js"></script>');
    $.extend({
        Chart3D: function (config) {
            if (!(this instanceof $.Chart3D)) {
                return new $.Chart3D(config);
            }
            var chart = this, _ISSVG = true, chartPaper;
            c = (function (c) {
                if (c && c.chart && c.chart.renderTo) {
                    c.chart = c.chart || {};
                    //统计图基本属性设置：类型(column,pie)，宽，高，颜色，样式，事件等。
                    c.chart.renderTo = c.chart.renderTo;
                    c.chart.type = c.chart.type || 'column';
                    c.chart.width = c.chart.width;
                    c.chart.height = c.chart.height;
                    c.colors = c.colors || ["#ff0f00", "#ff6600", "#ff9e01", "#fcd202", "#f8ff01", "#b0de09", "#04d215", "#0d8ecf", "#0d52d1", "#2a0cd0", "#8a0ccf", "#cd0d74"];
                    c.chart.style = c.chart.style || {};
                    c.chart.events = c.chart.events || {};
                    c.chart.events.click = c.chart.events.click;
                    c.credits = c.credits || {};
                    c.credits.enabled = typeof c.credits.enabled == "boolean" ? c.credits.enabled : false; //隐藏超链接
                    //标题内容，高度，样式
                    c.title = c.title || {};
                    c.title.text = c.title.text || ''; //标题内容
                    c.title.height = c.title.height || 25; //标题高度
                    c.title.style = c.title.style; //标题样式
                    //x轴数组
                    c.xAxis = c.xAxis || {};
                    c.xAxis.categories = c.xAxis.categories || []; //x轴数组
                    c.xAxis.labels = c.xAxis.labels || {};
                    c.xAxis.labels.align = c.xAxis.labels.align || "center"; //x轴字体居中
                    c.xAxis.labels.style = c.xAxis.labels.style; //x轴字体样式
                    c.xAxis.labels.rotation = c.xAxis.labels.rotation || 0; //x轴字体旋转
                    c.xAxis.labels.formatter = c.xAxis.labels.formatter; //X轴内容方法
                    //y轴
                    c.yAxis = c.yAxis || {};
                    c.yAxis.min = c.yAxis.min || 0; //y轴最小值
                    c.yAxis.title = c.yAxis.title || {};
                    c.yAxis.title.text = c.yAxis.title.text || ''; //y轴标题
                    c.yAxis.title.style = c.yAxis.title.style; //y轴标题样式
                    c.yAxis.labels = c.yAxis.labels || {}; //Y轴内容
                    c.yAxis.labels.formatter = c.yAxis.labels.formatter; //Y轴内容方法
                    //动画效果
                    c.animate = c.animate || {};
                    c.animate.text = c.animate.text || 'backOut'; //动画形式（linear、<>、backIn、backOut、elastic、bounce）
                    c.animate.delay = c.animate.delay || 100; //饼状延迟时间
                    c.animate.ms = c.animate.ms || 100; //饼状动画效果时长
                    c.animate.column = c.animate.column || {};
                    c.animate.column.delay = c.animate.column.delay || 20; //柱状延迟时间
                    c.animate.column.ms = c.animate.column.ms || 100; //柱状动画效果时长
                    //图例
                    c.legend = c.legend || {};
                    c.legend.layout = c.legend.layout || 'horizontal'; //图例横排或纵排
                    c.legend.backgroundColor = c.legend.backgroundColor || '#FFFFFF'; //图例背景颜色
                    c.legend.align = c.legend.align || 'center'; //图例水平位置
                    c.legend.verticalAlign = c.legend.verticalAlign || 'bottom'; //图例垂直位置
                    c.legend.x = c.legend.x || 0; //图例x轴坐标
                    c.legend.y = c.legend.y || 0; //图例y轴坐标
                    c.legend.floating = typeof c.legend.floating == "boolean" ? c.legend.floating : false; //图例是否float
                    c.legend.shadow = typeof c.legend.shadow == "boolean" ? c.legend.shadow : false; //图例是否显示
                    c.legend.enabled = typeof c.legend.enabled == "boolean" ? c.legend.enabled : true; //图例是否启用

                    c.tooltip = c.tooltip || {};
                    c.tooltip.formatter = c.tooltip.formatter; //鼠标移入时事件

                    c.plotOptions = c.plotOptions || {};
                    c.plotOptions.series = c.plotOptions.series || {};
                    c.plotOptions.series.point = c.plotOptions.series.point || {};
                    c.plotOptions.series.point.events = c.plotOptions.series.point.events || {};
                    c.plotOptions.series.point.events.click = c.plotOptions.series.point.events.click; //点击每列数据时事件

                    c.plotOptions.column = c.plotOptions.column || {};
                    c.plotOptions.column.stacking = c.plotOptions.column.stacking || ''; //柱状分组（normal）
                    c.plotOptions.column.depth3D = c.plotOptions.column.depth3D || 20; //3D效果厚度
                    c.plotOptions.column.colors = c.plotOptions.column.colors || ''; //柱状图颜色
                    c.plotOptions.column.cursor = c.plotOptions.column.cursor || 'pointer';
                    c.plotOptions.column.opacity = c.plotOptions.column.opacity || 0.9; //柱状图透明度
                    c.plotOptions.column.dataLabels = c.plotOptions.column.dataLabels || {};
                    c.plotOptions.column.dataLabels.enabled = typeof c.plotOptions.column.dataLabels.enabled == "boolean" ? c.plotOptions.column.dataLabels.enabled : false; //柱状内容是否启用
                    c.plotOptions.column.dataLabels.style = c.plotOptions.column.dataLabels.style || c.style; //柱状样式
                    c.plotOptions.column.dataLabels.formatter = c.plotOptions.column.dataLabels.formatter; //柱状内容显示事件

                    c.plotOptions.pie = c.plotOptions.pie || {};
                    c.plotOptions.pie.allowPointSelect = typeof c.plotOptions.allowPointSelect == "boolean" ? c.plotOptions.allowPointSelect : false; //饼图
                    c.plotOptions.pie.cursor = c.plotOptions.pie.cursor || "";
                    c.plotOptions.pie.dataLabels = c.plotOptions.pie.dataLabels || {};
                    c.plotOptions.pie.dataLabels.enabled = typeof c.plotOptions.pie.dataLabels.enabled == "boolean" ? c.plotOptions.pie.dataLabels.enabled : false; //饼图内容是否启用
                    c.plotOptions.pie.dataLabels.showInLegend = typeof c.plotOptions.pie.dataLabels.showInLegend == "boolean" ? c.plotOptions.pie.dataLabels.showInLegend : false; //饼图内容是否显示
                    //图数据
                    c.series = c.series || [];
                    (function (cols_) {
                        if (cols_) {
                            for (var i = 0; i < cols_.length; i++) {
                                var col = cols_[i];
                                col.name = col.name || ""; //名称
                                col.show = col.show || true; //是否显示
                                col.stack = col.stack || ''; //分组名
                                col.type = col.type; //数据类型（column,pie）
                                col.data = (function (colData_) {
                                    var arr = [];
                                    if (colData_) {
                                        for (var j = 0; j < colData_.length; j++) {
                                            var sData = {};
                                            var colData = colData_[j];
                                            //将参数统统转为json类型
                                            switch (Object.prototype.toString.call(colData)) {
                                                case '[object Number]':
                                                    sData.y = colData;
                                                    break;
                                                case '[object Array]':
                                                    if (!isNaN(colData[0])) {
                                                        sData.x = colData[0];
                                                    } else {
                                                        sData.name = colData[0];
                                                        sData.x = colData[0];
                                                    } if (!isNaN(colData[1])) {
                                                        sData.y = colData[1];
                                                    } else { sData.y = 0; }
                                                    break;
                                                default:
                                                    sData = colData;
                                                    break;
                                            }
                                            sData.color = sData.color || c.colors[j % c.colors.length]; //颜色
                                            arr.push(sData);
                                        }
                                    }
                                    return arr;
                                })(col.data);
                            }
                        }
                    })(c.series);
                } else {
                    c = null
                }
                chart.config = c;
                return c;
            })(config);
            var DataStack = [];
            //获取最大最小值，并整理分组数据。
            this.MaxMinValue = function () {
                DataStack = [];
                var _max = 0, _min = 0;
                for (var i = 0; i < chart.config.series.length; i++) {
                    if (chart.config.series[i].show) {
                        for (var j = 0; j < chart.config.series[i].data.length; j++) {
                            var nowValue = chart.config.series[i].data[j].y || _min;
                            if (config.plotOptions.column.stacking == "normal") {
                                var Data = {};
                                Data.name = config.xAxis.categories[j];
                                Data.stack = config.series[i].stack;
                                Data.MaxValue = nowValue;
                                var Has = false;
                                for (var k = 0; k < DataStack.length; k++) {
                                    if (DataStack[k].name == Data.name && DataStack[k].stack == Data.stack) {
                                        DataStack[k].MaxValue += Data.MaxValue;
                                        Has = true;
                                        if (DataStack[k].MaxValue > _max)
                                            _max = DataStack[k].MaxValue;
                                    }
                                }
                                if (Has == false) {
                                    DataStack.push(Data);
                                    if (Data.MaxValue > _max)
                                        _max = Data.MaxValue;
                                }
                            } else {
                                if (nowValue > _max)
                                    _max = nowValue;
                                if (nowValue < _min)
                                    _min = nowValue;
                            }
                        }
                    }
                }
                var Zero = 0;
                if (_max >= 0) {
                    while (_max < 1 && _max > 0) {
                        _max *= 10;
                        Zero--;
                    }
                    while (_max > 10) {
                        _max /= 10;
                        Zero++;
                    }
                    _max = parseInt(_max) + 1;
                    while (Zero != 0) {
                        if (Zero > 0) {
                            _max *= 10;
                            Zero--;
                        } if (Zero < 0) {
                            _max /= 10;
                            Zero++;
                        }
                    }
                }
                if (_min > 0)
                    _min = 0;
                return [_max, _min];
            };
            //颜色淡化或加重，用于立体图形颜色渐变
            this.colorShade = function (rgb, brite) {
                rgb = rgb.replace("#", "0x");
                var r, g, b;
                if (brite == 0)
                    return rgb;
                if (brite < 0) {
                    brite = (100 + brite) / 100;
                    r = ((rgb >> 16) & 0xFF) * brite;
                    g = ((rgb >> 8) & 0xFF) * brite;
                    b = (rgb & 0xFF) * brite;
                }
                else // bright > 0
                {
                    brite /= 100;
                    r = ((rgb >> 16) & 0xFF);
                    g = ((rgb >> 8) & 0xFF);
                    b = (rgb & 0xFF);

                    r += ((0xFF - r) * brite);
                    g += ((0xFF - g) * brite);
                    b += ((0xFF - b) * brite);

                    r = Math.min(r, 255);
                    g = Math.min(g, 255);
                    b = Math.min(b, 255);
                }
                return "#" + (parseInt(r)).toString(16).padLeft(2, "0") + (parseInt(g)).toString(16).padLeft(2, "0") + (parseInt(b)).toString(16).padLeft(2, "0");
            };
            //增加stirng类型左边填充字符。
            String.prototype.padLeft = function (b, c) {
                var d = this;
                while (d.length < b) {
                    d = c + d;
                }
                return d;
            };
            //默认样式
            this.dStyle = { color: "#000", lineHeight: "14px", fontFamily: "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif", fontSize: "11px", fill: "#666" };
            //样式转换
            this.SetStyle = function (dom, domStyle) {
                for (i in domStyle) {
                    dom.css(i, domStyle[i]);
                }
            };
            //柱状图显示方法
            this.Column = function (svg) {
                var titleX = 0, titleY = 0;
                //标题
                if (config.title.text != "") {
                    titleX = config.chart.width / 2, titleY = config.title.height;
                    svg.text(titleX, titleY, config.title.text).attr({ "text-anchor": "middle", font: "16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif " });
                }
                if (config.yAxis.title.text != "") {
                    var YtitleWidth = 20, YtitleHeight = config.chart.height / 2;
                    svg.text(YtitleWidth, YtitleHeight, config.yAxis.title.text).attr({ "text-anchor": "middle", font: "12px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif" }).transform("r270");
                }
                //X轴等分线
                //高度-标题高度-底线高度10，距离左边宽度-60
                var xTextHeight = 50, titleBorder = 6;
                //总高度-title高度-距离title高度-x轴文本高度-3D宽度=Y轴总高度
                var xAxisY = config.chart.height - titleY - titleBorder - xTextHeight - config.plotOptions.column.depth3D, yAxisX = 40;
                //Y轴等分线
                var gyAxis = svg.set();
                var MaxMin = this.MaxMinValue(), dengfen = 5, yAxisHeight = xAxisY / dengfen;
                var yHeightText = (MaxMin[0] - MaxMin[1]) / dengfen;
                var x1 = 0, x2 = 0, y1 = 0, y2 = 0;
                for (var i = 0; i <= dengfen; i++) {
                    //每条Y轴y坐标点=段高度*i+title高度+3D宽度+10
                    var yAxisY = yAxisHeight * i + titleY + config.plotOptions.column.depth3D + titleBorder;
                    yStyle = chart.dStyle;
                    yClassName = "";
                    var temp1 = 0;
                    if (yHeightText.toString().indexOf(".") != -1)
                        temp1 = yHeightText.toString().length - yHeightText.toString().indexOf(".") - 1;
                    var Ytext = yHeightText * (5 - i);
                    var yLabel = svg.text(yAxisX, yAxisY, Ytext.toFixed(temp1)).attr({ "text-anchor": "end" });
                    gyAxis.push(yLabel);
                    yLabel.value = Ytext.toFixed(temp1);
                    (function () {
                        var thisY = yLabel;
                        if (config.yAxis.labels.formatter) {
                            thisY.attr("text", config.yAxis.labels.formatter.call(thisY));
                        }
                    })();
                    var dArr = [];
                    dArr.push([yAxisX, yAxisY]);
                    dArr.push([yAxisX + config.plotOptions.column.depth3D, yAxisY - config.plotOptions.column.depth3D]);
                    dArr.push([chart.config.chart.width, yAxisY - config.plotOptions.column.depth3D]);
                    var lineD = this.CreatePathD(dArr);
                    var line = this.createPath(svg, yAxisX, lineD, {}, xClassName, "#c0c0c0", 1, "none", 1, 1);
                    gyAxis.push(line);
                    if (i == 0) {
                        x1 = yAxisX;
                        y1 = yAxisY;
                    } if (i == dengfen) {
                        x2 = yAxisX;
                        y2 = yAxisY;
                    }
                }
                //X轴等分线
                var xAxisWidth = (config.chart.width - yAxisX - config.plotOptions.column.depth3D) / config.xAxis.categories.length; //X轴每项宽度
                var gxAxis = svg.set();
                var xY = xAxisY + titleY + config.plotOptions.column.depth3D + titleBorder;
                for (var i = 0; i < config.xAxis.categories.length; i++) {
                    var xAxisX = yAxisX + xAxisWidth * i + (xAxisWidth / 2),
                    xStyle = chart.config.xAxis.labels.style,
                    xClassName = "";
                    var xLable = this.createText(svg, config.xAxis.categories[i], xAxisX, xY + 15, xStyle, xClassName, "middle");
                    xLable.value = config.xAxis.categories[i];
                    (function () {
                        var thisX = xLable;
                        if (config.xAxis.labels.formatter) {
                            thisX.attr("text", config.xAxis.labels.formatter.call(thisX));
                        }
                    })();
                    xLable.transform("r" + config.xAxis.labels.rotation);
                    gxAxis.push(xLable);
                    if (i != 0) {
                        var dArr = [];
                        dArr.push([yAxisX + xAxisWidth * i, xY]);
                        dArr.push([yAxisX + xAxisWidth * i, xY + 10]);
                        gxAxis.push(this.createLine(svg, dArr[0][0], dArr[0][1], dArr[1][0], dArr[1][1], xStyle, xClassName, "#000000", 1));
                    }
                }
                //左侧3D效果
                var x3 = x1 + config.plotOptions.column.depth3D;
                var y3 = y1 - config.plotOptions.column.depth3D;
                var x4 = x2 + config.plotOptions.column.depth3D;
                var y4 = y2 - config.plotOptions.column.depth3D;
                var ArrD = [];
                ArrD.push([x1, y1]);
                ArrD.push([x3, y3]);
                ArrD.push([x4, y4]);
                ArrD.push([x2, y2]);
                var d = this.CreatePathD(ArrD, true);
                var Pathstyle = { opacity: 0.2 };
                this.createPath(svg, x2, d, Pathstyle, "", "#000", 1, "#aaa", 1, 0.2);
                //底边3D效果
                var x5 = config.chart.width;
                var y5 = y4;
                var x6 = config.chart.width - config.plotOptions.column.depth3D;
                var y6 = y2;
                var ArrDX = [];
                ArrDX.push([x2, y2]);
                ArrDX.push([x4, y4]);
                ArrDX.push([x5, y5]);
                ArrDX.push([x6, y6]);
                d = this.CreatePathD(ArrDX, true);
                Pathstyle = { opacity: 0.6 }
                this.createPath(svg, x6, d, Pathstyle, "", "#000", 1, "#aaa", 1, 0.6);
                var colNum = 0, stackArr = [];
                for (var i = 0; i < config.series.length; i++) {
                    if (config.series[i].show) {
                        if (config.plotOptions.column.stacking == "normal") {
                            var has = false;
                            for (var j = 0; j < stackArr.length; j++) {
                                if (stackArr[j] == config.series[i].stack) {
                                    has = true;
                                }
                            } if (has == false) {
                                stackArr.push(config.series[i].stack);
                                colNum++;
                            }
                        }
                        else { colNum++; }
                    }
                }
                if (colNum != 0) {
                    //画柱
                    var Padding = config.plotOptions.column.pointPadding || 0;
                    var gGraphWidth = config.plotOptions.column.pointWidth || xAxisWidth * 2 / 3 / colNum - Padding;
                    var Graphx = yAxisX + (xAxisWidth - (gGraphWidth + Padding) * colNum) / 2;
                    var gGraphAll = svg.set();
                    var Colcount = 0;
                    for (var j = 0; j < config.xAxis.categories.length; j++) {
                        if (j > 0) {
                            Graphx = Graphx + xAxisWidth;
                        }
                        var xgpp = 0;
                        for (var i = 0; i < config.series.length; i++) {
                            var gGraph = svg.set();
                            if (config.series[i].show) {
                                var iGraphx = Graphx + (gGraphWidth + Padding) * xgpp;
                                xgpp++;
                                var zIndex = 1;
                                var nowData = config.series[i].data[j];
                                var nowValue = nowData.y;
                                var GraphHight = xAxisY * nowValue / MaxMin[0];
                                var iGraphy = xAxisY + titleY + config.plotOptions.column.depth3D + 6 - GraphHight;
                                var opacity = config.plotOptions.column.opacity;
                                var fillColor;
                                //判断是否多组显示，若是则取config.color颜色，单组取当前颜色
                                if (config.series.length > 1) {
                                    fillColor = config.colors[i];
                                } else {
                                    fillColor = nowData.color;
                                }
                                var stackTotal = nowValue;
                                //柱状分组
                                if (config.plotOptions.column.stacking == "normal") {
                                    for (var k = 0; k < DataStack.length; k++) {
                                        if (DataStack[k].name == config.xAxis.categories[j] && DataStack[k].stack == config.series[i].stack) {
                                            DataStack[k].ColHeight = DataStack[k].ColHeight || 0;
                                            iGraphy -= DataStack[k].ColHeight
                                            DataStack[k].ColHeight += GraphHight;
                                            stackTotal = DataStack[k].MaxValue;
                                            for (var l = 0; l < stackArr.length; l++) {
                                                if (DataStack[k].stack == stackArr[l]) {
                                                    iGraphx = Graphx + (gGraphWidth + Padding) * l;
                                                }
                                            }
                                        }
                                    }
                                }
                                var Col = this.CreateGraph(svg, nowValue, iGraphx, iGraphy, gGraphWidth, GraphHight, "", "", "#000", 0, fillColor, zIndex, opacity, Colcount);
                                Colcount++;
                                //给柱子赋属性值
                                Col[0].x = config.xAxis.categories[j]; //x轴值
                                Col[0].category = config.xAxis.categories[j]; //x轴名称分类
                                Col[0].y = nowValue; //当前y轴值
                                Col[0].point = chart.config.series[i]; //当前数据
                                Col[0].point.stackTotal = stackTotal; //当前总数据
                                Col[0].series = chart.config.series[i]; //当前数据
                                (function () {
                                    var thisCol = Col;
                                    var _x = iGraphx, _y = iGraphy;
                                    var txt = "";
                                    //柱状事件绑定
                                    if (config.plotOptions.series.point.events.click) {
                                        thisCol.click(function () { config.plotOptions.series.point.events.click.call(thisCol[0]); });
                                    } if (config.tooltip.formatter) {
                                        txt = config.tooltip.formatter.call(thisCol[0]) || "";
                                    }
                                    //柱状移入事件绑定
                                    thisCol.mousemove(function (e) {
                                        var _x = (e.pageX || e.clientX + document.body.scrollLeft - document.body.clientLeft) - $("#" + config.chart.renderTo).offset().left + 10;
                                        var _y = (e.pageY || e.clientY + document.body.scrollTop - document.body.clientTop) - $("#" + config.chart.renderTo).offset().top - 40;
                                        chart.tooltipShow(svg, _x, _y, txt);
                                    });
                                })();
                                gGraph.push(Col);
                            }
                            gGraphAll.push(gGraph);
                        }
                    }
                    //移除事件绑定
                    gGraphAll.mouseout(function () {
                        chart.tooltipHidden(svg);
                    });
                }
                if (config.legend.enabled == true) {
                    //显示图例
                    chart.ShowColumnName(svg);
                }
                //增加移入事件产生的文本
                this.TooltipText(svg);
            };
            //获取字符串字符数
            this.GetStrLength = function (s) {
                var strlength = 0;
                for (var j = 0; j < s.length; j++) {
                    if (s.charCodeAt(j) > 255) strlength += 2;
                    else strlength++;
                }
                return strlength;
            };
            //图例显示方法
            this.ShowColumnName = function (svgdoc) {
                var gColumn = svgdoc.set();
                if (config.series.length > 0) {
                    var bColor = config.legend.backgroundColor;
                    var x = config.legend.x;
                    var y = config.legend.y;
                    var align = config.legend.align;
                    var verticalAlign = config.legend.verticalAlign;
                    var layout = config.legend.layout;
                    var width = 30, Hight = 3, gX = 8, gY = 0;
                    var RectBorth = chart.CreateRect(svgdoc, "", 0.5, 0.5, width, Hight, {}, "", "#555", 1, bColor, 1, 0.5, 5, 5);
                    gColumn.push(RectBorth);
                    var textStyle = "";
                    for (var i = 0; i < config.series.length; i++) {
                        var color = config.colors[i];
                        var color2 = "#aaaaaa";
                        if (config.series[i].show == false) {
                            color = color2;
                            color2 = config.series[i].data[0].color;
                        }
                        var sl = this.GetStrLength(config.series[i].name);
                        var gwidth = sl * 9 + 21;
                        if (layout == "horizontal") {
                            width = Math.min((width + gwidth), config.chart.width);
                            gX += gwidth;
                            if (gX > config.chart.width) {
                                gX = 8 + gwidth;
                                Hight += 20;
                            }
                        } else {
                            Hight = 3 + i * 20;
                            gX = 8 + gwidth;
                            width = (gwidth > width) ? gwidth : width;
                        }
                        gY = Hight;
                        var gName = svgdoc.set().data("color", color2).data("dataName", config.series[i].name);
                        var textCol = chart.createText(svgdoc, chart.config.series[i].name, 25 + gX - gwidth, gY + 5, {}, "", "start");
                        textCol.data("color", color2).data("dataName", config.series[i].name);
                        textCol.attr({ font: "11px Fontin-Sans, Arial" });
                        $(textCol.node).css("cursor", "pointer");
                        gName.push(textCol);
                        gName.push(chart.CreateRect(svgdoc, "", gX - gwidth, gY, 16, 12, { cursor: "pointer" }, "", color, 0, color, 3, 0.9, 2, 2));
                        (function () {
                            var thisgName = gName;
                            gName.click(function (event) {
                                var evColor = thisgName[0].data("color");
                                var ColorRect = thisgName[1];
                                thisgName[0].data("color", ColorRect.attr("fill"));
                                ColorRect.attr("fill", evColor);
                                for (var i = 0; i < config.series.length; i++) {
                                    var item = config.series[i];
                                    if (item.name == thisgName[0].data("dataName")) {
                                        item.show = !item.show;
                                    }
                                }
                                svgdoc.clear();
                                chart.Column(svgdoc);
                            });
                        })();
                        //gName.transform("t" + (gX - gwidth) + " " + gY);
                        gColumn.push(gName);
                    }
                    if (config.legend.align == "right") {
                        x = config.chart.width - width - Math.abs(config.legend.x);
                    } if (config.legend.align == "center") {
                        x = (config.chart.width - width) / 2;
                    } if (verticalAlign == "middle") {
                        y = config.chart.height / 2;
                    } if (verticalAlign == "bottom") {
                        y = config.chart.height - Hight - 20;
                    }
                    if (x + width >= config.chart.width) {
                        x = config.chart.width - width - 20;
                    } if (y + Hight + 20 >= config.chart.height) {
                        y = config.chart.height - Hight - 20;
                    }
                    RectBorth.attr("width", width);
                    RectBorth.attr("height", Hight + 20);
                    gColumn.transform("t" + x + " " + y);
                }
                return gColumn;
            };
            this.TooltipText = function (svg) {
                //创建移动的提示信息
                var TooltipG = svg.set();
                var tooltip = this.CreateRect(svg, "", 0, 0, 60, 30, "", "", "#555", 1, "#eee", 1, 0.5, 5, 5);
                tooltip.id = config.chart.renderTo + "_tooptip";
                var tooltip_text = this.createText(svg, "", 10, 15, null, "", "start").attr({ font: "12px Fontin-Sans, Arial" });
                tooltip.hide();
                tooltip_text.hide();
                TooltipG.push(tooltip);
                TooltipG.push(tooltip_text);
            }
            //鼠标移入显示方法
            this.tooltipShow = function (svgdoc, x, y, textValue) {
                var tooltipG = svgdoc.getById(config.chart.renderTo + "_tooptip");
                tooltipG.show();
                tooltipG.next.show();
                var tooltip = $(tooltipG.node);
                var tooltip_text = $(tooltipG.next.node);
                textValue = textValue.replace(/\<br\>/g, "\n").replace(/\<br\/\>/g, "\n");
                var arrs = textValue.split('\n');
                tooltipG.next.attr("text", textValue);
                var toolWidth = 10, toolHight = arrs.length * 20;
                for (var i = 0; i < arrs.length; i++) {
                    var tValue = arrs[i].replace("<br/>", "");
                    if (Raphael.svg) {
                        var item = tooltip_text.children().eq(i);
                        if (item != null) {
                            if (tValue.indexOf('<b>') >= 0) {
                                tValue = tValue.replace("<b>", "").replace("</b>", "");
                                item.attr("font-weight", "bold");
                            }
                            item.text(tValue);
                            var dy = i == 0 ? 3 : 15;
                            item.attr("dy", dy);
                        }
                    } else {
                        textValue = textValue.replace("<b>", "").replace("</b>", "");
                        tooltipG.next.attr("text", textValue);
                        tValue = tValue.replace("<b>", "").replace("</b>", "")
                    }
                    var tWidth = this.GetStrLength(tValue) * 6 + 5;
                    if (tWidth > toolWidth) {
                        toolWidth = tWidth;
                    }
                }
                tooltipG.attr({ "width": 20 + toolWidth, "height": toolHight });
                if (x + 20 + toolWidth > config.chart.width) {
                    x = x - 20 - toolWidth;
                } if (tooltip.attr("height") > 20) {
                    y = y - (tooltipG.attr("height") - 20);
                }
                tooltipG.transform("t" + x + " " + y);
                tooltipG.next.transform("t" + (x + 5) + " " + y);
            };
            //鼠标移除隐藏方法
            this.tooltipHidden = function (svgdoc) {
                var tooltipG = svgdoc.getById(config.chart.renderTo + "_tooptip");
                tooltipG.hide();
                tooltipG.next.hide();
            };
            //创建一个3D立体柱状图
            this.CreateGraph = function (svgdoc, text, x, y, width, height, style, className, stroke, strokeWidth, fill, zIndex, opacity, Col_i) {
                width = config.plotOptions.column.pointWidth || width;
                var d3 = config.plotOptions.column.depth3D || 0;
                var gGraph = svgdoc.set();
                if (d3 > 0) {
                    var o1 = [x, y];
                    var o2 = [x + width, y];
                    var o3 = [x + width, y + height];
                    var o4 = [x, y + height];
                    var o5 = [x + d3, y - d3];
                    var o6 = [x + d3 + width, y - d3];
                    var o7 = [x + d3 + width, y - d3 + height];
                    var o8 = [x + d3, y - d3 + height];
                    //下
                    var d = this.CreateD(o4[0], o4[1], o8[0], o8[1], o7[0], o7[1], o3[0], o3[1]);
                    var d2 = this.CreateD(o4[0], o4[1], o8[0], o8[1], o7[0], o7[1], o3[0], o3[1]);
                    var M_down = this.createPath(svgdoc, x, d, style, className, stroke, strokeWidth, this.colorShade(fill, -30), zIndex - 1, opacity);
                    var anim = Raphael.animation(this.elattrs(d, d2), config.animate.column.ms, config.animate.text);
                    M_down.hide();
                    (function () {
                        var thisM = M_down;
                        var Ms = config.animate.column.delay * Col_i;
                        setTimeout(function () { thisM.show() }, Ms);
                    })();
                    gGraph.push(M_down);
                    //后
                    var M_back = this.CreateRect(svgdoc, text, o5[0], o5[1] + height, width, 0, style, className, stroke, strokeWidth, this.colorShade(fill, -20), zIndex - 1, opacity);
                    anim = Raphael.animation({ height: height, y: o5[1] }, config.animate.column.ms, config.animate.text);
                    M_back.animate(anim.delay(config.animate.column.delay * Col_i));
                    gGraph.push(M_back);
                    //左
                    d = this.CreateD(o4[0], o4[1], o8[0], o8[1], o8[0], o8[1], o4[0], o4[1]);
                    var d2 = this.CreateD(o1[0], o1[1], o5[0], o5[1], o8[0], o8[1], o4[0], o4[1]);
                    var M_left = this.createPath(svgdoc, x, d, style, className, stroke, strokeWidth, this.colorShade(fill, -10), zIndex - 1, opacity);
                    anim = Raphael.animation(this.elattrs(d, d2), config.animate.column.ms, config.animate.text);
                    M_left.animate(anim.delay(config.animate.column.delay * Col_i));
                    gGraph.push(M_left);
                    //右
                    d = this.CreateD(o3[0], o3[1], o7[0], o7[1], o7[0], o7[1], o3[0], o3[1]);
                    d2 = this.CreateD(o2[0], o2[1], o6[0], o6[1], o7[0], o7[1], o3[0], o3[1]);
                    var M_right = this.createPath(svgdoc, x, d, style, className, stroke, strokeWidth, this.colorShade(fill, -10), zIndex, opacity);
                    anim = Raphael.animation(this.elattrs(d, d2), config.animate.column.ms, config.animate.text);
                    M_right.animate(anim.delay(config.animate.column.delay * Col_i));
                    gGraph.push(M_right);
                    //上
                    d = this.CreateD(o4[0], o4[1], o8[0], o8[1], o7[0], o7[1], o3[0], o3[1]);
                    d2 = this.CreateD(o1[0], o1[1], o5[0], o5[1], o6[0], o6[1], o2[0], o2[1]);
                    var M_top = this.createPath(svgdoc, x, d, style, className, stroke, strokeWidth, this.colorShade(fill, 30), zIndex, opacity);
                    anim = Raphael.animation(this.elattrs(d, d2), config.animate.column.ms, config.animate.text);
                    M_top.animate(anim.delay(config.animate.column.delay * Col_i));
                    M_top.hide();
                    (function () {
                        var thisM = M_top;
                        var Ms = config.animate.column.delay * Col_i;
                        setTimeout(function () { thisM.show() }, Ms);
                    })();
                    gGraph.push(M_top);
                } //前
                var M_before = this.CreateRect(svgdoc, text, x, y + height, width, 0, style, className, stroke, strokeWidth, fill, zIndex, opacity);
                var anim = Raphael.animation({ height: height, y: y }, config.animate.column.ms, config.animate.text);
                M_before.animate(anim.delay(config.animate.column.delay * Col_i));
                gGraph.push(M_before);
                return gGraph;
            };
            //动画路径移动轨迹
            this.elattrs = function (d1, d2) {
                var elattrs = [{ path: d2 }, { path: d1}], now = 1;
                return elattrs[+(now = !now)];
            };
            //饼图创建方法
            this.Pie = function (svg) {
                var black = svg.set();
                //black.push(this.createPath(svg, 0, d, config.chart.style, "#000000", 1, "none", 0, 1));
                var titleX = 0, titleY = 0;
                //标题
                if (config.title.text != "") {
                    titleX = config.chart.width / 2, titleY = config.title.height;
                    var titleText = this.createText(svg, config.title.text, titleX, titleY, config.title.style, config.title.className, "middle");
                    titleText.attr({ font: "20px Fontin-Sans, Arial" });
                }
                //椭圆起点
                var PicTop = [titleX, titleY + 20];
                //椭圆Y轴
                var PicRy = (config.chart.height - titleY - config.plotOptions.column.depth3D) / 2 - 20;
                //椭圆X轴
                var PicRx = config.chart.width / 3;
                //当纵坐标大于横坐标时，取较小值
                if (PicRy > PicRx) {
                    PicRy = PicRx;
                }
                PicRx = 1.2 * PicRy;
                //椭圆圆心
                var PicO = [PicTop[0], PicTop[1] + PicRy];
                var sum = 0, Data = [];
                for (var i = 0; i < chart.config.series[0].data.length; i++) {
                    var nowValue = config.series[0].data[i];
                    nowValue.selected = nowValue.selected || false;
                    //nowValue.x=nowValue.name;
                    sum += nowValue.y;
                    //值大于0
                    if (nowValue.y > 0) {
                        Data.push(nowValue);
                    } else if (sum == 0 && i + 1 == chart.config.series[0].data.length) {//或者值全是0保留最后一条数据
                        Data.push(nowValue);
                    }
                }
                //计算扇形起止点和扇形顺序
                var CountZ = 0, PicStart = [PicTop[0], PicTop[1]];
                for (var i = 0; i < Data.length; i++) {
                    var Z = Data[i].y / sum * 360;
                    //无数据时
                    if (sum == 0 && Data.length == 1) { Z = 360; }
                    CountZ += Z;
                    var PicEnd = this.getPicNext(PicO, [PicRx, PicRy], CountZ);
                    if (i + 1 == Data.length) {
                        PicEnd[0] = PicTop[0] - 0.01;
                        PicEnd[1] = PicTop[1];
                    }
                    Data[i].CenterPoint = this.getPicNext(PicO, [PicRx, PicRy], (CountZ - (Z / 2)));
                    var Px = Data[i].CenterPoint[0] - PicO[0];
                    var Py = Data[i].CenterPoint[1] - PicO[1];
                    var quad = 1;
                    if (Px >= 0 && Py < 0)
                        quad = 1;
                    else if (Px > 0 && Py >= 0)
                        quad = 2;
                    else if (Px <= 0 && Py > 0)
                        quad = 3;
                    else
                        quad = 4;
                    Data[i].quad = quad;
                    Data[i].startPoint = PicStart;
                    Data[i].endPoint = PicEnd;
                    Data[i].percentage = Data[i].y / sum;
                    Data[i].index = i;
                    if (sum == 0) { Data[i].percentage = 1; }
                    Data[i].CountZ = CountZ;
                    PicStart = PicEnd;
                }
                //调换扇形画图顺序（svg中后画标签覆盖前面画的标签）
                for (var i = 0; i < Data.length; i++) {
                    for (var j = i + 1; j < Data.length; j++) {
                        if (Data[i].CountZ > 180) {
                            var temp = Data[i];
                            if (Data[i].percentage >= 0.5) {
                                Data[i] = Data[j];
                                Data[j] = temp;
                            } else if (Data[i].CountZ <= Data[j].CountZ) {
                                Data[i] = Data[j];
                                Data[j] = temp;
                            }
                        }
                    }
                }
                //绘图并给与动画
                for (var i = 0; i < Data.length; i++) {
                    var PicCol = svg.set();
                    var fillColor = Data[i].color;
                    var opacity = config.plotOptions.column.opacity;
                    var Z = Data[i].percentage * 360;
                    var depth = config.plotOptions.column.depth3D;
                    var delayMs = (Data[i].index + 1) * config.animate.delay;
                    var Ms = config.animate.delay;
                    var d = this.CreatePathD([PicO], true);
                    if (depth != 0) {
                        var PicNext3D = [Data[i].startPoint[0], Data[i].startPoint[1] + depth];
                        var PicMove3D = [Data[i].endPoint[0], Data[i].endPoint[1] + depth];
                        var PicO3D = [PicO[0], PicO[1] + depth];
                        d = this.CreatePathD([PicO3D], true);
                        //底面
                        var d2 = this.getPicD(PicNext3D, PicO3D, [PicRx, PicRy], PicMove3D, Z);
                        var PicBack = this.createPath(svg, PicRx, d, {}, "", "#ffffff", 1, this.colorShade(fillColor, -30), 0, 1);
                        var anim = Raphael.animation(this.elattrs(d, d2), Ms, config.animate.text);
                        PicBack.animate(anim.delay(delayMs));
                        PicCol.push(PicBack);
                        //扇形左面
                        d = this.CreatePathD([PicO, PicO3D], true);
                        var Arr = [PicO, PicO3D, PicNext3D, Data[i].startPoint];
                        d2 = this.CreatePathD(Arr, true);
                        var Picleft = this.createPath(svg, PicRx, d, {}, "", "#ffffff", 1, this.colorShade(fillColor, -20), 0, 1);
                        anim = Raphael.animation(this.elattrs(d, d2), Ms, config.animate.text);
                        Picleft.animate(anim.delay(delayMs));
                        PicCol.push(Picleft);
                        //扇形右面
                        d = this.CreatePathD([PicO, PicO3D], true);
                        Arr = [PicO, PicO3D, PicMove3D, Data[i].endPoint];
                        d2 = this.CreatePathD(Arr, true);
                        var PicRight = this.createPath(svg, PicRx, d, {}, "", "#ffffff", 1, this.colorShade(fillColor, -20), 0, 1);
                        anim = Raphael.animation(this.elattrs(d, d2), Ms, config.animate.text);
                        PicRight.animate(anim.delay(delayMs));
                        PicCol.push(PicRight);
                    }
                    //上面
                    d = this.CreatePathD([PicO], true);
                    var d2 = this.getPicD(Data[i].startPoint, PicO, [PicRx, PicRy], Data[i].endPoint, Data[i].percentage * 360);
                    var PicTopM = this.createPath(svg, PicRx, d, {}, "", "#ffffff", 1, fillColor, 0, 1);
                    anim = Raphael.animation(this.elattrs(d, d2), Ms, config.animate.text);
                    PicTopM.animate(anim.delay(delayMs));
                    PicCol.push(PicTopM);
                    //线与文字
                    var LinEnd = [0, 0];
                    if (Data[i].CenterPoint[0] == PicO[0])
                        LinEnd[1] = 30;
                    else if (Data[i].CenterPoint[1] == PicO[1])
                        LinEnd[0] = 30;
                    else {
                        var V = (Data[i].CenterPoint[0] - PicO[0]) / (Data[i].CenterPoint[1] - PicO[1]);
                        LinEnd[1] = Math.sqrt(900 / (Math.pow(V, 2) + 1));
                        LinEnd[0] = Math.abs(V * LinEnd[1]);
                    }
                    if (Data[i].quad == 3 || Data[i].quad == 4)
                        LinEnd[0] = 0 - LinEnd[0];
                    if (Data[i].quad == 1 || Data[i].quad == 4)
                        LinEnd[1] = 0 - LinEnd[1];
                    var LineD = [];
                    LineD.push([Data[i].CenterPoint[0], Data[i].CenterPoint[1]]);
                    LineD.push([Data[i].CenterPoint[0] + LinEnd[0], Data[i].CenterPoint[1] + LinEnd[1]]);
                    LineD.push([Data[i].CenterPoint[0] + LinEnd[0] * 2, Data[i].CenterPoint[1] + LinEnd[1]]);
                    var DataText = Data[i].name + ":" + (Data[i].percentage * 100).toFixed(3) + "%";
                    //判断是否显示线与文字
                    if (config.plotOptions.pie.dataLabels.showInLegend) {
                        PicCol.push(this.createPath(svg, LineD[0][0], this.CreatePathD(LineD, false), {}, "", "#777", 0.5, "none"));
                        //文字
                        var textAnthor = "left";
                        if (Data[i].CountZ > 180) {
                            //textAnthor="end";
                            LineD[2][0] -= this.GetStrLength(DataText);
                        }
                        var PicColText = this.createText(svg, DataText, LineD[2][0], LineD[2][1], chart.dStyle, "", textAnthor);
                        PicCol.push(PicColText);
                    }
                    //给扇形绑定显示数据。
                    PicCol[0].Move = LinEnd;
                    PicCol[0].series = Data[i];
                    PicCol[0].series.name = Data[i].name || config.xAxis.categories[i];
                    PicCol[0].point = Data[i];
                    PicCol[0].x = config.xAxis.categories[i] || Data[i].name;
                    PicCol[0].y = Data[i].y;
                    PicCol[0].percentage = (Data[i].percentage * 100);
                    PicCol[0].attr("opacity", 1);
                    //给每个PieCol方法。
                    (function () {
                        var thisPicCol = PicCol;
                        var txt = "";
                        if (c.tooltip.formatter) {
                            txt = c.tooltip.formatter.call(thisPicCol[0]) || "";
                        }
                        thisPicCol.mousemove(function (e) {
                            var _x = (e.pageX || e.clientX + document.body.scrollLeft - document.body.clientLeft) - $("#" + config.chart.renderTo).offset().left;
                            var _y = (e.pageY || e.clientY + document.body.scrollTop - document.body.clientTop) - $("#" + config.chart.renderTo).offset().top - 40;
                            chart.tooltipShow(svg, _x, _y, txt);
                        });
                        thisPicCol.mouseout(function () {
                            chart.tooltipHidden(svg);
                        });
                        thisPicCol.click(function () {
                            if (thisPicCol[0].series.selected) {
                                thisPicCol.transform("t0 0");
                                thisPicCol[0].series.selected = false;
                            } else {
                                thisPicCol[0].series.selected = true;
                                thisPicCol.transform("t" + thisPicCol[0].Move[0] + " " + thisPicCol[0].Move[1]);
                            }
                        });
                    })();
                }
                this.TooltipText(svg);
            };
            //获取绘制扇形path路径
            this.getPicD = function (PicTop, PicO, PicR, PicMove, Z) {
                var Isbig = 0;
                if (Z > 180)
                    Isbig = 1;
                var d = " M" + PicO[0] + " " + PicO[1] + " L" + PicTop[0] + " " + PicTop[1] + " A " + PicR[0] + " " + PicR[1] + " 0 " + Isbig + " 1 " + PicMove[0] + " " + PicMove[1] + " L" + PicO[0] + " " + PicO[1] + " Z";
                return d;
            };
            //根据扇形角度计算下一个点的坐标位置
            this.getPicNext = function (PicO, PicR, Z) {
                var PicNext = [0, 0];
                var ZPI = 0
                if (Z > 0 && Z <= 90) {
                    ZPI = (Math.PI * (Z)) / 180;
                } if (Z > 90 && Z <= 180) {
                    ZPI = (Math.PI * (180 - Z)) / 180;
                } if (Z > 180 && Z <= 270) {
                    ZPI = (Math.PI * (Z - 180)) / 180;
                } if (Z > 270 && Z <= 360) {
                    ZPI = (Math.PI * (360 - Z)) / 180;
                }
                PicNext[1] = Math.sqrt(Math.pow(PicR[0], 2) * Math.pow(PicR[1], 2) / (Math.pow(PicR[0], 2) + Math.pow(PicR[1], 2) * Math.pow(Math.tan(ZPI), 2)));
                PicNext[0] = PicNext[1] * Math.tan(ZPI);
                if (Z > 0 && Z <= 90) {
                    PicNext[0] = PicO[0] + PicNext[0];
                    PicNext[1] = PicO[1] - PicNext[1];
                } if (Z > 90 && Z <= 180) {
                    PicNext[0] = PicO[0] + PicNext[0];
                    PicNext[1] = PicO[1] + PicNext[1];
                } if (Z > 180 && Z <= 270) {
                    PicNext[0] = PicO[0] - PicNext[0];
                    PicNext[1] = PicO[1] + PicNext[1];
                } if (Z > 270 && Z <= 360) {
                    PicNext[0] = PicO[0] - PicNext[0];
                    PicNext[1] = PicO[1] - PicNext[1];
                }
                return PicNext;
            };
            //获取Path标签的路径
            this.CreatePathD = function (xyArr, _IsClose) {
                var PathD = "";
                if (_ISSVG) {
                    PathD = "M";
                    for (var i = 0; i < xyArr.length; i++) {
                        if (i != 0) { PathD = PathD + " L"; }
                        PathD = PathD + " " + xyArr[i][0] + " " + xyArr[i][1];
                    }
                    if (_IsClose) { PathD = PathD + "Z"; }
                } else {
                    PathD = "m";
                    for (var i = 0; i < xyArr.length; i++) {
                        if (i == 1) { PathD = PathD + " l"; }
                        PathD = PathD + " " + xyArr[i][0] + "," + xyArr[i][1];
                    }
                    if (_IsClose) { PathD = PathD + " x e"; }
                }
                return PathD;
            };
            //获取简单路径（四边形）
            this.CreateD = function (x1, y1, x2, y2, x3, y3, x4, y4) {
                return "M" + x1 + " " + y1 + " L" + x2 + " " + y2 + " L" + x3 + " " + y3 + " L" + x4 + " " + y4 + "Z";
            };
            //创建矩形
            this.CreateRect = function (svgdoc, text, x, y, width, height, style, className, stroke, strokeWidth, fill, zIndex, opacity, rx, ry) {
                var DOM = svgdoc.rect(x, y, width, height, rx).attr({ "stroke": stroke, "stroke-width": strokeWidth, "fill": fill, "zIndex": zIndex, "opacity": opacity });
                return DOM;
            };
            //创建路径
            this.createPath = function (svgdoc, x, d, style, className, stroke, strokeWidth, fill, zIndex, opacity) {
                var DOM = svgdoc.path(d).attr({ "stroke": stroke, "stroke-width": strokeWidth, "fill": fill, "zIndex": zIndex, "opacity": opacity });
                return DOM;
            };
            //创建文本
            this.createText = function (svgdoc, text, x, y, style, className, textAnchor) {
                text = text.replace(/\<br\>/g, "\n").replace(/\<br\/\>/g, "\n");
                var DOM = svgdoc.text(x, y, text).attr("text-anchor", textAnchor);
                if (Raphael.svg) {
                    chart.SetStyle($(DOM.node), style);
                    $(DOM.node).attr("class", className);
                    var arrs = text.split('\n');
                    for (var i = 0; i < arrs.length; i++) {
                        var tValue = arrs[i].replace("<br/>", ""), bold = false;
                        var item = $(DOM.node).children().eq(i);
                        if (item != null) {
                            if (tValue.indexOf('<b>') >= 0) {
                                bold = true;
                                tValue = tValue.replace("<b>", "").replace("</b>", "");
                                item.attr("font-weight", "bold");
                            }
                            item.text(tValue);
                            item.attr("dy", i * 15 + 3);
                        }
                    }
                } else {
                    text = text.replace("<b>", "").replace("</b>", "");
                    DOM.attr('text', text);
                }
                return DOM;
            };
            //创建线
            this.createLine = function (svgdoc, x1, y1, x2, y2, style, className, strokeColor, strokeWeight) {
                var DOM = svgdoc.path("M" + x1 + " " + y1 + " L" + x2 + " " + y2).attr({ "stroke": strokeColor, "stroke-weight": strokeWeight });
                return DOM;
            };
            //重置高宽
            this.setSize = function (width, height) {
                chartPaper.setSize(width, height);
            };
            //实例入口
            this.init = function () {
                var Divrender = $('#' + config.chart.renderTo);
                if (!config.chart.height || !config.chart.width) {
                    if (!Divrender.height()) {
                        var ParDoc = Divrender.parent();
                        var NowHeight = ParDoc.height();
                        for (var i = 0; i < ParDoc.children().length; i++) {
                            var Pheight = $(ParDoc.children()[i]).height();
                            if (Pheight) {
                                NowHeight -= Pheight;
                            }
                        }
                        config.chart.height = NowHeight;
                        config.chart.width = ParDoc.width();
                    } else {
                        config.chart.height = Divrender.height();
                        config.chart.width = Divrender.width();
                    }
                } if (!config.chart.height) {
                    config.chart.height = 400;
                } if (!config.chart.width) {
                    config.chart.width = document.body.clientWidth;
                }
                Divrender.html("");
                this.SetStyle(Divrender, config.style);
                config.chart.width = config.chart.width * 0.99;
                var divPaper = $("<div>").attr("id", config.chart.renderTo + "Paper").width(config.chart.width).height(config.chart.height);
                Divrender.append(divPaper);
                var Paper = Raphael(config.chart.renderTo + "Paper", config.chart.width, config.chart.height);
                (function () {
                    var thisGroup = Divrender;
                    if (config.chart.events.click) {
                        Divrender.click(function () { config.chart.events.click.call(thisGroup); });
                    }
                })();
                switch (config.chart.type) {
                    case "column":
                        this.Column(Paper);
                        return Paper;
                        break;
                    case "pie":
                        this.Pie(Paper);
                        return Paper;
                        break;
                    default:
                        return new Highcharts.Chart(config);
                        break;
                }
            };
            //启动init()
            chartPaper = this.init();
        }
    });
})(jQuery);